#ifndef OPENTREETHREAD_H
#define OPENTREETHREAD_H

#include <QThread>
#include <QTreeWidget>

class OpenTreeThread : public QThread
{
    Q_OBJECT
public:
    explicit OpenTreeThread(const QString& src_path, int& file_count, QTreeWidget* self, QObject *parent = nullptr);

    void OpenProTree(const QString& src_path, int& file_count, QTreeWidget* self);

protected:
    virtual void run();

private:
    void RecursiveProTree(const QString& src_path, int& file_count, QTreeWidget* self,
                          QTreeWidgetItem* root, QTreeWidgetItem* parent, QTreeWidgetItem* preitem);

    QString _src_path;
    int _file_count;
    QTreeWidget* _self; // 给哪一个 QTreeWdget 中去添加
    bool _bstop = false;
    QTreeWidgetItem* _root;

public slots:
    void SlotCancelOpenProgress();

signals:
    void SigFinishProgress(int file_count);
    void SigUpdateProgress(int file_count);
};

#endif // OPENTREETHREAD_H
